package com.httpapi;


import android.util.Log;

import okhttp3.logging.HttpLoggingInterceptor;

/**
 * @author mzw 2019-07-01
 */
public class HttpLogger implements HttpLoggingInterceptor.Logger {
    private static String TAG = HttpLogger.class.getSimpleName();
//很神奇的字符串builder
//    private StringBuilder mMessage = new StringBuilder();

    @Override
    public void log(String message) {
        int start=0;
        int end = 2001;
        String temp ="";
        while (start<message.length()){
            if(end>message.length()){
                end = message.length();
            }
            temp = message.substring(start,end);
            Log.d(TAG,temp);
            start+=2001;
            end+=2001;
        }
//        if (message.startsWith("--> POST")) {
//            mMessage.setLength(0);
//        }
//        if ((message.startsWith("{") && message.endsWith("}"))
//                || (message.startsWith("[") && message.endsWith("]"))) {
//            message = Logger.formatJson(message);
//        }
//        mMessage.append(message.concat("\n"));
//        if (message.startsWith("<-- END HTTP")) {
//            Logger.e(TAG, mMessage.toString());
//        }
    }
}